<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <title>粉丝福利</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" type="text/css" href="dist/swipeslider.css">
</head>
<body>
    <div style="position:absolute;bottom:0;left:0px;width:100%;height:100%;overflow:auto;z-index:1;padding-bottom: 50px;">
        <!--轮播图-->
        <figure id="full_feature" class="swipslider">
            <!--                <ul class="sw-slides">-->
            <!--                    <li class="sw-slide"><img src="img/summer_beach.jpg" alt=""></li>-->
            <!--                </ul>-->
        </figure>

        <!--    商品介绍-->
        <div class="container" id="title">
            <div id="record">
                <!--        <h4>iPhone XS 64GB 4G金色</h4>-->
                <!--            <button type="button" class="btn btn-default btn-xs" style="border-radius: 20px;color: #f45c59;border-color: #f45c59;" disabled>寻宝中</button>-->
                <!--            <small style="color: #2aabd2;">点击下方立即参与，即可获得一次寻宝机会</small>-->
            </div>
            <div id="times">
                <!--            <hr style="margin-top: 5px;margin-bottom: 0;">-->
                <!--            <small style="color: #2aabd2;float: left;">2019-10-10 10:10:00截止</small>-->
                <!--            <small style="color: #2aabd2;float: right;">2019-10-10 10:10:00开奖</small>-->
            </div>
        </div>
        <!--    <div class="container" id="statistics" style="font-size: 12px;margin-top: 5px;">-->
        <!--        <span>第S1期 100人已参与</span>-->
        <!--    </div>-->
        <hr style="margin-top: 0;margin-bottom: 0;">
        <!--    图文详情-->
        <div class="container" id="content" style="padding-top: 10px;">
            <!--        图文详情（富文本）-->
        </div>
    </div>
    <div style="position: absolute;bottom: 0;left: 0;height:50px;width: 100%;z-index: 2;background: #fff;">
        <button type="button" class="btn btm-sm" style="width: 100%;height: 50px;" id="submit"></button>
    </div>
    <script src="js/jquery.js"></script>
    <script src="js/touche.js"></script>
    <script src="js/p-pull-refresh.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="dist/swipeslider.min.js"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script src="js/sha1.js"></script>
    <script src="js/config.js"></script>
    <script src="js/public2.js"></script>
    <script type="text/javascript">
        let data = {};
        let act_id = getQueryVariable('act_id');
        if(!act_id){
            alert('未传参数');
            location.replace('./index.html');
        }
        function afterVerify(){
            $.post(baseUrl+'client/goods',{
                act_id:act_id,
            },function(result){
                afterRequest(result);
            },'json');
        }

        function afterRequest(result){
            if(result.code === 0){
                data = result.data;
                //轮播图
                let full_feature = '<ul class="sw-slides">';
                for(let i=0;i<data.goods_imgs.length;i++){
                    full_feature += '<li class="sw-slide"><img src="' +data.goods_imgs[i] +'" alt=""></li>';
                }
                full_feature += '</ul>';
                $('#full_feature').html(full_feature).swipeslider();
                //title
                let drawed = data.drawed;
                let type = data.type;
                if((data.status === 0 && data.participate === 0)||(data.winning === 1 && !data.receive && !data.expired)){
                    //未参与或已点击
                    $('#submit').addClass('btn-gold').html(drawed);//按钮文字
                } else {
                    $('#submit').attr('disabled','disabled').html(drawed);//按钮文字
                }
                let title = '<p style="font-size: 18px;margin: 5px 0;">'+data.goods_name+'</p>';
                title += '<p><span style="font-size: 12px;line-height: 25px;color: #ff0000;">第'+data.act_no+'期&nbsp;&nbsp;'+data.total+'人已参与</span><button class="btn btn-xs" style="border-radius: 20px;float:right;background: #ff0000;color: #fff;">查看详情</button></p>';
                $('#record').html(title);
                title = '<hr style="margin-top: 5px;margin-bottom: 0;">';
                title += '<small style="float: left;margin: 10px 0;color: #ff0000;">'+data.end_time +'截止</small>';
                title += '<small style="float: right;margin: 10px 0;color: #ff0000;">'+data.draw_time+'开奖</small></div>';
                $('#times').html(title);
                //统计
                $('#content').html(data.detail);
            }
        }

        $('#submit').click(()=>{
            if (data.status === 0 && data.participate === 0) {//参与抽奖
                //参与抽奖
                $.post(baseUrl+'client/participate',{
                    act_id:act_id,
                },function(result){
                    if(result.code === 0){
                        location.href='./success.html?participate_id='+result.data.participate_id;
                    }else{
                        alert(result.msg);
                    }
                },'json');
            } else if (data.winning === 1 && !data.receive) {//去领奖
                if(data.virtual){
                    alert('此奖品为虚拟物品，请在当前公众号联系在线客服领取');
                } else {
                    location.href = './address.html?act_id=' + act_id;
                }
            }
        });

        $('#slidershow').carousel({
            interval: 2000 // in milliseconds
        })

        $('#record').click(function(){
            location.href = './record.html?act_id=' + act_id;
        });

    </script>
    <script src="js/verify.js"></script>
</body>
</html>
